package com.qfmy.mapper.assistant;

import model.entity.assistant.AiAnswer;
import model.entity.assistant.FeedBack;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.mapper.assistant
 * @date 2025/5/18
 * @description 智能助手
 */
@Mapper
@SuppressWarnings("all")
public interface ChatMapper {

    /**
     * 插入AI回答
     * @param aiAnswer
     */
    void insert(AiAnswer aiAnswer);

    /**
     * 插入用户反馈
     * @param feedBack
     */
    @Insert("insert into feed_back(content,user_id) values(#{content},#{userId})")
    void insertFeedBack(FeedBack feedBack);

    /**
     * 获取历史记录
     * @param userId
     * @return
     */
    List<AiAnswer> history(@Param("userId") Long userId);

    /**
     * 删除历史记录
     * @param time
     * @param userId
     */
    @Delete("delete from ai_answer where create_time = #{time} and user_id = #{userId}")
    void deleteByTime(String time, Long userId);

    /**
     * 根据时间获取历史记录
     * @param time
     * @param userId
     * @return
     */
    List<AiAnswer> getHistoryByTime(String time, Long userId);

}
